package PJ;

import java.util.ArrayList;
import java.util.Scanner;

public class Entrance {
		public static int playernumber=0;
		public static ArrayList<Player> players=new ArrayList<Player>();
		public static void main(String[] args) throws InterruptedException {
		System.out.println("====================     游戏开始       ======================");
		while(true){
		System.out.println("请输入参加的玩家数:");
		Scanner input = new Scanner(System.in);
		playernumber = input.nextInt();
		if(playernumber<2){
			System.out.println("参与玩家数在2-4人之间，请重新输入");
		}
		if(playernumber>4){
			System.out.println("参与玩家数在2-4人之间，请重新输入");
		}
		if(playernumber>=2&&playernumber<=4){
			System.out.println("设置成功，本次游戏共有"+playernumber+"名玩家，祝您游戏愉快");
			break;
		}
		}
		if(playernumber==2){
			Player player1=new Player(15000, 15000, 100, 0, 0, 1, "玩家1", 1, 0);
			Player player2=new Player(15000, 15000, 100, 0, 0, 1, "玩家2", 2, 0);
			players.add(player1);
			players.add(player2);
		}
		if(playernumber==3){
			Player player1=new Player(15000, 15000, 100, 0, 0, 1, "玩家1", 1, 0);
			Player player2=new Player(15000, 15000, 100, 0, 0, 1, "玩家2", 2, 0);
			Player player3=new Player(15000, 15000, 100, 0, 0, 1, "玩家3", 3, 0);
			players.add(player1);
			players.add(player2);
			players.add(player3);
		}
		if(playernumber==4){
			Player player1=new Player(15000, 15000, 100, 0, 0, 1, "玩家1", 1, 0);
			Player player2=new Player(15000, 15000, 100, 0, 0, 1, "玩家2", 2, 0);
			Player player3=new Player(15000, 15000, 100, 0, 0, 1, "玩家3", 3, 0);
			Player player4=new Player(15000, 15000, 100, 0, 0, 1, "玩家4", 4, 0);
			players.add(player1);
			players.add(player2);
			players.add(player3);
			players.add(player4);
		}
		while(true){
		Date.print();
		if(Date.totalday%7!=6&&Date.totalday%7!=0){
		for(int i=0;i<=9;i++){
			Stock.stocksystem[i].run();
		}
		System.out.println("今天是工作日，股市正常开市");
		}else{
		System.out.println("今天是双休日，股市休市");
		}
		for(int i=0;i<players.size();i++){
			players.get(i).move();
		}
	}
	}
}
